package com.sun.draw.api;

import com.sun.draw.param.DrawParamContent;
import com.sun.draw.result.DrawConfig;

/**
 * 执行抽奖抽象命令
 * 
 * @ClassName: AbstractDrawCommand
 * @author sunt
 * @date 2018年1月9日
 * @version V1.0
 */
public abstract class AbstractDrawCommand implements IDrawCommand {

	private IDrawCommand drawCommand;

	public IDrawCommand setNextCommand(IDrawCommand drawCommand) {
		this.drawCommand = drawCommand;
		return drawCommand;
	}

	public boolean isNext() {
		return true;
	}

	/**
	 * 模板方法
	 */
	public final boolean run(DrawParamContent drawParamContent) {
		if (isNext()) {
			boolean b = execute(drawParamContent);
			if (b) {
				if (null != drawCommand) {
					// 本节点处理不了 交给下一个节点处理请求
					drawCommand.run(drawParamContent);
				}
			} else {//未中奖
				drawParamContent.getWinDrawInfo().setWinFlag(DrawConfig.FALSE);
			}

			return b;
		}

		return true;
	}
}
